<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/30
 * Time: 15:04
 */
namespace app\web\controller;
use cmf\controller\HomeBaseController;
use app\portal\model\BranchesModel;

class BranchesController extends HomeBaseController{

    public static $lang_arr=array();
    public function _initialize()
    {
        if(empty(self::$lang_arr)){
            self::$lang_arr=$this->read('zh-us');
        }
    }
    /**
     * 网点列表
     */
    public function getBranchesList(){
        $param = $this->request->param();
        $branchesList = array('德国','波兰','法国','意大利','西班牙','长沙','武汉','成都','宁波（义乌）','郑州');
        if ($param['languageType'] == 2){
            $branchesList=$this->changeLang($branchesList,self::$lang_arr);
        }
        foreach($branchesList as $key=>$v)
        {
            $branchesListNew[$key]['branchesList']=$v;
        }
        return $this->json('0','请求成功',$branchesListNew) ;
    }

    /**
     * 网点加盟申请
     */
    public function getJoinBranchesInfo(){
        $param = $this->request->param();
        $result = $this->validate($param, 'Branches');
        if ($result !== true) {
            return $this->json('1003', $result);
        } else {
            $branchesModel = new BranchesModel();
            $joinBranchesInfo = $branchesModel->insert($param);
            return $this->json('0', '请求成功');
        }
    }

}